// Calculate.cpp : implementation file
//

#include "stdafx.h"
#include "ThreadTest.h"
#include "CalculateThread.h"
#include "ThreadTestDlg.h"

// CCalculate

IMPLEMENT_DYNCREATE(CCalculateThread, CWinThread)

CCalculateThread::CCalculateThread()
{
}

CCalculateThread::~CCalculateThread()
{
}

BOOL CCalculateThread::InitInstance()
{
	// TODO:  perform and per-thread initialization here
	return TRUE;
}

int CCalculateThread::ExitInstance()
{
	// TODO:  perform any per-thread cleanup here
	return CWinThread::ExitInstance();
}

void CCalculateThread::OnCalculate(UINT wParam,LONG lParam)
{
	int nTmpt=0;
	for(int i=0;i<=(int)wParam;i++)
	{
		nTmpt=nTmpt+i;
	}
	Sleep(500);
	::PostMessage((HWND)(GetMainWnd()->GetSafeHwnd()),WM_DISPLAY,nTmpt,NULL);
}

BEGIN_MESSAGE_MAP(CCalculateThread, CWinThread)
	ON_THREAD_MESSAGE(WM_CALCULATE,OnCalculate)
END_MESSAGE_MAP()


// CCalculate message handlers
